<template>
	<view>
		<view class="container">
			<uni-nav-bar left-icon="back" left-text="返回" title="我的收藏" @clickLeft="goBack" color="white"
				backgroundColor="rgb(55, 138, 241)"></uni-nav-bar>
      <view v-for="(item,index) in dataList">
        <uni-card :title="item.name" sub-title="" :extra="'价格:' + item.price" :thumbnail="avatar" @click="details(item.id)">
          <text class="uni-body">{{item.introduction}}</text>
        </uni-card>
      </view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				avatar: require('@/static/pdficon.jpeg'),
        dataList: []
			}
		},
		methods: {
			goBack() {
				uni.navigateBack();
			},
      details(id){
        uni.navigateTo({
          url: '/pages/index/details?id='+id
        })
      }
		},
		onLoad() {
      let that = this;
      this.$axios.get('/collection/queryCollecting',{
        headers: {
          token: localStorage.getItem('token')
        }
      }).then( res=> {
        //TODO 这里接口格式写错了，多了个data，以后可能会改吧
        that.dataList = res.data.data.data; //多了一个data
      })
		}
	}
</script>

<style>
	.container {
		padding: 0px;
		font-size: 14px;
		line-height: 24px;
	}
</style>
